package com.qf.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/7 16:41
 */
public class MyAroundAdvice implements MethodInterceptor {
    /**
     * 环绕通知代码
     * @param methodInvocation ：执行的方法
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("1.苹果多少钱啊？");
        Object[] arguments = methodInvocation.getArguments();
        if (arguments == null){
            arguments = new Object[1];
        }
        arguments[0] = 1;
        //回核心代码
        methodInvocation.proceed();
        System.out.println("3.能便宜一点吗？");
        arguments[0] = 2;
        //回核心代码
        methodInvocation.proceed();
        System.out.println("5.北京就不能便宜一点啊？");
        arguments[0] = 3;
        //回核心代码
        methodInvocation.proceed();
        return null;
    }
}
